var config = require('config');
cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
    },

    // use this for initialization
    onLoad: function () {
        var togle = this.getComponent(cc.Toggle);
        if(config.music_on){
            togle.isChecked = true;
        }else{
            togle.isChecked = false;
        }
    },
    
    checkMusic: function(toggle){
        if(toggle.isChecked){
            config.music_on = true;
            cc.audioEngine.resumeMusic();
            cc.log("resume music");
        }else{
            config.music_on = false;
            cc.audioEngine.pauseMusic();
            cc.log("pause music");
        }
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
